/*返回顶部*/
/*返回顶部上下移动，点击返回顶部*/
let returnTop=document.getElementsByClassName("returnTop")[0];

document.addEventListener('scroll',function(){
    let topJuLi = document.documentElement.scrollTop;
    if(topJuLi > 300) {
        returnTop.style.display = "block";
    } else {
        returnTop.style.display = "none";
    }
},true);
returnTop.addEventListener('click',function(){
    turnTop();
},true)
function turnTop() {
    let backTopTimer = setInterval(function() {
        let topH = document.documentElement.scrollTop || document.body.scrollTop;
        let backTopSpeed = Math.floor(-topH / 8);
        if(topH > 0) {
            document.documentElement.scrollTop = document.body.scrollTop = topH + backTopSpeed;
        } else {
            clearInterval(backTopTimer);
        }
    }, 10);
}
setInterval(function(){
    moveTopBottom();
},600);
function moveTopBottom(){
    returnTop.style.bottom="120px";
    setTimeout(function(){
        returnTop.style.bottom="100px";
    },300)
}
/*点击下面的标签返回不同位置*/
let tenLabel=document.getElementsByClassName("tenLabel");
/*生活标签*/
tenLabel[0].onclick=function(){
    returnPosition(0);
    returnPositionX(0);
}
tenLabel[1].onclick=function(){
    returnPosition(450);
    returnPositionX(450);
}
tenLabel[2].onclick=function(){
    returnPosition(840);
    returnPositionX(840);
}
tenLabel[3].onclick=function(){
    returnPosition(1200);
    returnPositionX(1200);
}
tenLabel[4].onclick=function(){
    returnPosition(1590);
    returnPositionX(1590);
}
tenLabel[5].onclick=function(){
    returnPosition(2000);
    returnPositionX(2000);
}
tenLabel[6].onclick=function(){
    returnPosition(2550);
    returnPositionX(2550);
}
tenLabel[7].onclick=function(){
    returnPosition(2920);
    returnPositionX(2920);
}
tenLabel[8].onclick=function(){
    returnPosition(3300);
    returnPositionX(3300);
}
tenLabel[9].onclick=function(){
    returnPosition(3400);
    returnPositionX(3400);
}
function returnPosition(e) {
    let backTopTimer = setInterval(function() {
        let topH = document.documentElement.scrollTop || document.body.scrollTop;
        // let backTopSpeed = Math.floor(-topH / 8);
        if(topH > e) {
            document.documentElement.scrollTop = document.body.scrollTop = topH -30;
        }else{
            clearInterval(backTopTimer);
        }
    }, 10);
}
function returnPositionX(e) {
    let backTopTimer = setInterval(function() {
        let topH = document.documentElement.scrollTop || document.body.scrollTop;
        // let backTopSpeed = Math.floor(-topH / 8);
        if(topH < e) {
            document.documentElement.scrollTop = document.body.scrollTop = topH +30;
        }else{
            clearInterval(backTopTimer);
        }
    }, 10);
}
function positionBackgroundColor(e){
    for(let i=0;i<10;i++) tenLabel[i].style.backgroundColor="";
    for(let i=0;i<10;i++) tenLabel[i].style.color="black";
    tenLabel[e].style.backgroundColor="#42bbfd";
    tenLabel[e].style.color="#ffffff";
}
tenLabel[0].style.backgroundColor="#42bbfd";
tenLabel[0].style.color="#ffffff";
document.onscroll=function(){
    let topJuLi = document.documentElement.scrollTop;
    if(topJuLi>=0&&topJuLi<=400)positionBackgroundColor(0);
    if(topJuLi>=400&&topJuLi<=800)positionBackgroundColor(1);
    if(topJuLi>=800&&topJuLi<=1150)positionBackgroundColor(2);
    if(topJuLi>=1150&&topJuLi<=1540)positionBackgroundColor(3);
    if(topJuLi>=1540&&topJuLi<=1950)positionBackgroundColor(4);
    if(topJuLi>=1950&&topJuLi<=2500)positionBackgroundColor(5);
    if(topJuLi>=2500&&topJuLi<=2870)positionBackgroundColor(6);
    if(topJuLi>=2870&&topJuLi<=3250)positionBackgroundColor(7);
    if(topJuLi>=3250&&topJuLi<=3350)positionBackgroundColor(8);
    if(topJuLi>=3350)positionBackgroundColor(9);
}

